package test.security;

import java.io.UnsupportedEncodingException;

public class Security {

	public static String encrypt(String source){
		int loop = 0;
		int len = 0;
		String result = null;
		char[] temp = null;
		
		if(source==null){
			result = null;
		}else if(source.equals("")){
			result = "";
		}else{
			len = source.length();
			
			if(len%2==1){
				source += " ";
				len += 1;
			}
			
			temp = source.toCharArray();
			
			for(loop=0;loop<len;loop++){
				temp[loop] += 100;
			}
			
			result = String.valueOf(temp);
			result = AsciiToChineseString(result);
		}
		
		return result;
	}
	
	public static String AsciiToChineseString(String s){
		if(s==null)
			return s;
		
		char[] orig = s.toCharArray();
		byte[] dest = new byte[orig.length];
		
		for(int i=0;i<orig.length;i++)
			dest[i] = (byte)(orig[i]&0xFF);
		
		try {
			return new String(dest, "GBK");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public static void main(String args[]){
		System.out.println(Security.encrypt("ewf"));

	}
}
